<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0,viewport-fit=cover"><title>HTML基础学习 | SuperXCR</title><meta name="author" content="SuperXCR"><meta name="copyright" content="SuperXCR"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="认识HTML1-1元素的结构HTML标签 “&lt; p&gt;” 就是一个典型的HTML标签。 HTML标签的特点  由尖括号包围关键词组成，比如：、、、等 通常成对出现。结束多了一个“&#x2F;“ 有的单个出现 、   1-2 HTML的嵌套第一个元素： 1&lt;p&gt;HTML是一门伟大的语言!&lt;&#x2F;p&gt; 开始： 结束 第二个元素： 1&lt;div&gt;&lt;p&gt;HTML是">
<meta property="og:type" content="article">
<meta property="og:title" content="HTML基础学习">
<meta property="og:url" content="https://liqur.xyz/SuperXCR/3ce8deb9.html">
<meta property="og:site_name" content="SuperXCR">
<meta property="og:description" content="认识HTML1-1元素的结构HTML标签 “&lt; p&gt;” 就是一个典型的HTML标签。 HTML标签的特点  由尖括号包围关键词组成，比如：、、、等 通常成对出现。结束多了一个“&#x2F;“ 有的单个出现 、   1-2 HTML的嵌套第一个元素： 1&lt;p&gt;HTML是一门伟大的语言!&lt;&#x2F;p&gt; 开始： 结束 第二个元素： 1&lt;div&gt;&lt;p&gt;HTML是">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://liqur-1309874423.cos.ap-shanghai.myqcloud.com/h2.webp">
<meta property="article:published_time" content="2022-09-01T01:00:00.000Z">
<meta property="article:modified_time" content="2022-11-10T06:29:40.668Z">
<meta property="article:author" content="SuperXCR">
<meta property="article:tag" content="前端">
<meta property="article:tag" content="HTML">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://liqur-1309874423.cos.ap-shanghai.myqcloud.com/h2.webp"><link rel="shortcut icon" href="/img/favicon.png"><link rel="canonical" href="https://liqur.xyz/SuperXCR/3ce8deb9.html"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: undefined,
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  dateSuffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isAnchor: false,
  percent: {
    toc: true,
    rightside: false,
  }
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'HTML基础学习',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2022-11-10 14:29:40'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
    win.getCSS = (url,id = false) => new Promise((resolve, reject) => {
      const link = document.createElement('link')
      link.rel = 'stylesheet'
      link.href = url
      if (id) link.id = id
      link.onerror = reject
      link.onload = link.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        link.onload = link.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(link)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><!-- hexo injector head_end start --><link rel="stylesheet" href="https://cdn.cbd.int/hexo-butterfly-clock-anzhiyu/lib/clock.min.css" /><link rel="stylesheet" href="https://cdn.cbd.int/hexo-butterfly-tag-plugins-plus@latest/lib/assets/font-awesome-animation.min.css" media="defer" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.cbd.int/hexo-butterfly-tag-plugins-plus@latest/lib/tag_plugins.css" media="defer" onload="this.media='all'"><script src="https://cdn.cbd.int/hexo-butterfly-tag-plugins-plus@latest/lib/assets/carousel-touch.js"></script><!-- hexo injector head_end end --><meta name="generator" content="Hexo 5.4.2"></head><body><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="https://i.loli.net/2021/02/24/5O1day2nriDzjSu.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">16</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">15</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">8</div></a></div><hr/></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://liqur-1309874423.cos.ap-shanghai.myqcloud.com/h2.webp')"><nav id="nav"><span id="blog-info"><a href="/" title="SuperXCR"><span class="site-name">SuperXCR</span></a></span><div id="menus"><div id="toggle-menu"><a class="site-page" href="javascript:void(0);"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">HTML基础学习</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2022-09-01T01:00:00.000Z" title="发表于 2022-09-01 09:00:00">2022-09-01</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2022-11-10T06:29:40.668Z" title="更新于 2022-11-10 14:29:40">2022-11-10</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/HTML/">HTML</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="HTML基础学习"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h3 id="认识HTML"><a href="#认识HTML" class="headerlink" title="认识HTML"></a>认识HTML</h3><h4 id="1-1元素的结构"><a href="#1-1元素的结构" class="headerlink" title="1-1元素的结构"></a>1-1元素的结构</h4><p>HTML标签</p>
<p>“&lt; p&gt;” 就是一个典型的HTML标签。</p>
<p>HTML标签的特点</p>
<ol>
<li>由尖括号包围关键词组成，比如：<p>、<h1>、<div>、<span>等</li>
<li>通常成对出现。结束多了一个<strong>“/“</strong></li>
<li>有的单个出现 <input>、<img></li>
</ol>
<p><img src="https://liqur-1309874423.cos.ap-shanghai.myqcloud.com/SuperXCR/2.jpg" alt="img"></p>
<h4 id="1-2-HTML的嵌套"><a href="#1-2-HTML的嵌套" class="headerlink" title="1-2 HTML的嵌套"></a>1-2 HTML的嵌套</h4><p>第一个元素：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">p</span>&gt;</span>HTML是一门伟大的语言!<span class="tag">&lt;/<span class="name">p</span>&gt;</span></span><br></pre></td></tr></table></figure>
<p>开始：<p> 结束</p></p>
<p>第二个元素：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">div</span>&gt;</span><span class="tag">&lt;<span class="name">p</span>&gt;</span>HTML是一门伟大的语言！<span class="tag">&lt;/<span class="name">p</span>&gt;</span><span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br></pre></td></tr></table></figure>
<p>开始：<div> 结束：</div></p>
<h4 id="1-3-完整的html文档结构"><a href="#1-3-完整的html文档结构" class="headerlink" title="1-3 完整的html文档结构"></a>1-3 完整的html文档结构</h4><p>1.&lt; !DOCTYPE html&gt;</p>
<p>(1).作用：指明文档类型  ，HTML版本</p>
<p>(2).位置：位于文档第一行，&lt; html &gt;前</p>
<p>(3).大小写都可</p>
<p>(4).没有结束标签</p>
<p>2.&lt; html lang=”en”&gt;…&lt; /html&gt;</p>
<p>(1)告知浏览器文档类型为HTML文档</p>
<p>(2)<html> 与</html>限制文档开始 结束点。头部由<head> 定义，主体为<body> 定义</p>
<p>(3)lang属性(语言属性) ：做一些针对指定语言的辅助操作，’en’ 表示英文</p>
<p>3.标签属性</p>
<p>(1)标签可有零个或多个属性，之间要用空格隔开</p>
<p>(2)标签可以有更多信息，通常为key=”value”</p>
<p>(3)常见的标签属性：class,id,style,lang,src等</p>
<p>4.文档头部</p>
<p>(1).head 定义头部 。通常用于 样式表，提供元素信息。</p>
<p>(2)<title>...</title> 定义文档标题，也即网页标签的标题</p>
<p>(3)一个<head> 元素必须包含且只能包含一个<title> 元素</p>
<p>补充：元信息：又叫元数据，就是描述数据的数据。这里指文档的概要信息</p>
<p>5.文档主题<body>...<!-- hexo injector body_end start --><script>
    // 全局变量声明区域
    var fdata = {
      apiurl: 'https://hexo-friendcircle-api-ai9d4hwad-anzhiyu-c.vercel.app/api',
      initnumber: 20, //【可选】页面初始化展示文章数量
      stepnumber: 10, //【可选】每次加载增加的篇数
      error_img: 'https://npm.elemecdn.com/akilar-candyassets/image/404.gif' //【可选，头像图片加载失败时的默认头像】
    }
    //存入本地存储
    localStorage.setItem("fdatalist",JSON.stringify(fdata))
    </script>
    <script defer src="https://npm.elemecdn.com/hexo-filter-fcircle/assets/js/fetch.min.js"></script><script data-pjax>
  function butterfly_clock_anzhiyu_injector_config(){
    var parent_div_git = document.getElementsByClassName('sticky_layout')[0];
    var item_html = '<div class="card-widget card-clock"><div class="card-glass"><div class="card-background"><div class="card-content"><div id="hexo_electric_clock"><img class="entered loading" id="card-clock-loading" src="https://cdn.cbd.int/hexo-butterfly-clock-anzhiyu/lib/loading.gif" style="height: 120px; width: 100%;" data-ll-status="loading"/></div></div></div></div></div>';
    console.log('已挂载butterfly_clock_anzhiyu')
    if(parent_div_git) {
      parent_div_git.insertAdjacentHTML("afterbegin",item_html)
    }
  }
  var elist = 'null'.split(',');
  var cpage = location.pathname;
  var epage = 'all';
  var qweather_key = 'b16a1fa0e63c46a4b8f28abfb06ae3fe';
  var gaud_map_key = 'e2b04289e870b005374ee030148d64fd&s=rsv3';
  var baidu_ak_key = 'undefined';
  var flag = 0;
  var clock_rectangle = '112.982279,28.19409';
  var clock_default_rectangle_enable = 'false';

  for (var i=0;i<elist.length;i++){
    if (cpage.includes(elist[i])){
      flag++;
    }
  }

  if ((epage ==='all')&&(flag == 0)){
    butterfly_clock_anzhiyu_injector_config();
  }
  else if (epage === cpage){
    butterfly_clock_anzhiyu_injector_config();
  }
  </script><script src="https://widget.qweather.net/simple/static/js/he-simple-common.js?v=2.0"></script><script data-pjax src="https://cdn.cbd.int/hexo-butterfly-clock-anzhiyu/lib/clock.min.js"></script><script async src="/js/ali_font.js"></script><!-- hexo injector body_end end --></body></p>
<p>(1).body 元素定义文档主体，包含文档的所有内容(比如超文本、超链接、图像、表格和列表等等)</p>
<h4 id="1-4-HTML中的注释"><a href="#1-4-HTML中的注释" class="headerlink" title="1-4 HTML中的注释"></a>1-4 HTML中的注释</h4><!-- --> 标签表示注释



#### 1-5 认识MDN

 MDN：https://developer.mozilla.org/zh-CN/docs/Web/HTML

学习web的地方

![img](https://liqur-1309874423.cos.ap-shanghai.myqcloud.com/SuperXCR/9.png)



<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">audio</span> <span class="attr">controls</span>=<span class="string">&quot;controls&quot;</span> <span class="attr">src</span>=<span class="string">&quot;https://document.youkeda.com/P3-1-HTML-CSS/1.2/nocturne.mp3&quot;</span> <span class="attr">muted</span>&gt;</span></span><br><span class="line">        您的浏览器不支持 <span class="tag">&lt;<span class="name">code</span>&gt;</span>audio<span class="tag">&lt;/<span class="name">code</span>&gt;</span> 标签</span><br><span class="line">    <span class="tag">&lt;/<span class="name">audio</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">body</span>&gt;</span></span><br></pre></td></tr></table></figure>
<p><img src="https://liqur-1309874423.cos.ap-shanghai.myqcloud.com/SuperXCR/10.png" alt="img"></p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">label</span> <span class="attr">for</span>=<span class="string">&quot;file&quot;</span>&gt;</span>File progress:<span class="tag">&lt;/<span class="name">labellabel</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">progress</span> <span class="attr">id</span>=<span class="string">&quot;file&quot;</span> <span class="attr">max</span>=<span class="string">&quot;100&quot;</span> <span class="attr">value</span>=<span class="string">&quot;50&quot;</span>&gt;</span> 50% <span class="tag">&lt;/<span class="name">progress</span>&gt;</span></span><br></pre></td></tr></table></figure>
<h4 id="2-1-块状和内联标签"><a href="#2-1-块状和内联标签" class="headerlink" title="2-1 块状和内联标签"></a>2-1 块状和内联标签</h4><p><img src="https://liqur-1309874423.cos.ap-shanghai.myqcloud.com/SuperXCR/1.png" alt="img"></p>
<p><img src="https://liqur-1309874423.cos.ap-shanghai.myqcloud.com/SuperXCR/2.png" alt="img"></p>
<p>为了使图片与文字分离，将文字与图片分别用<p>包裹</p>
<p>&lt; p&gt;与&lt; /p&gt;之间为块状标签</p>
<p><img> 为内联标签</p>
<h4 id="2-2-标题标签"><a href="#2-2-标题标签" class="headerlink" title="2-2 标题标签"></a>2-2 标题标签</h4><p>&lt; h1&gt;  &lt; /h1&gt; 到 &lt; h6&gt; &lt; /h6&gt; 不断缩小</p>
<p>标题间不可以跨级写，影响美观</p>
<h4 id="2-3-常用文本标签"><a href="#2-3-常用文本标签" class="headerlink" title="2-3 常用文本标签"></a>2-3 常用文本标签</h4><p>&lt; p&gt;&lt; /p&gt; 段落标签，可以写文本，图片和表单项</p>
<p>内联标签</p>
<p>&lt; strong&gt; &lt; /strong&gt; 加粗字体</p>
<p>&lt; span&gt; &lt; /span&gt; 格式与文本相同，主要是在写的时候显示不同</p>
<h4 id="2-4-图片标签"><a href="#2-4-图片标签" class="headerlink" title="2-4 图片标签"></a>2-4 图片标签</h4><p>&lt; img src=”” alt=””&gt;插入图片</p>
<p>alt=””;当图片不能显示是显示文字</p>
<p>也可以插入gif</p>
<h4 id="2-5-链接标签"><a href="#2-5-链接标签" class="headerlink" title="2-5 链接标签"></a>2-5 链接标签</h4><p>&lt; a&gt;为内联标签，点击可跳转指定网址</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;https://liqur.xyz&quot;</span>&gt;</span>SuperXCR<span class="tag">&lt;/<span class="name">a</span>&gt;</span></span><br></pre></td></tr></table></figure>
<p>&lt; a&gt;标签内部可以放文字，其他元素(段落、图像、多媒体)</p>
<p>链接也可以以图片的形式展现</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;https://liqur.xyz/&quot;</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">img</span> <span class="attr">src</span>=<span class="string">&quot;xxx&quot;</span> /&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">a</span>&gt;</span></span><br></pre></td></tr></table></figure>
<p>链接标签属性</p>
<p>href</p>
<p> 给出链接指出的网。值为一个URL或者一个锚点</p>
<p>title</p>
<p>target</p>
<p>target属性值有_ self、_blank、_parent、_top</p>
<p>1、_self 链接在当前页面打开</p>
<p>2、_blank 链接在新的页面打开</p>
<h4 id="2-6-列表"><a href="#2-6-列表" class="headerlink" title="2-6 列表"></a>2-6 列表</h4><p>HTML提供两种列表</p>
<p><strong>无序列表</strong></p>
<p>&lt; ul&gt;</p>
<p>特点，每段文字前有一个 实心圆</p>
<p><strong>有序列表</strong></p>
<p>特点，有序号排列</p>
<p>&lt; ol&gt;</p>
<p><code>有序和无序列表都是用&lt; li&gt;添加文字</code></p>
<h4 id="3-1-form标签"><a href="#3-1-form标签" class="headerlink" title="3-1 form标签"></a>3-1 form标签</h4><p>用于 信息填写 和 交互式表单控件</p>
<p>form标签的两个属性</p>
<p>1.action：处理此表单信息的程序URL，所述表格信息将在表单提交时被发送到定义的地址</p>
<p>2.method：它的值可以是GET或POST，用来规定如何发送表单信息</p>
<p>格式</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">&lt;!-- &lt;form&gt;是块状标签，要注意：&lt;form&gt;标签不能嵌套&lt;form&gt;标签 --&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">form</span> <span class="attr">action</span>=<span class="string">&quot;&quot;</span>&gt;</span></span><br><span class="line">  <span class="comment">&lt;!-- 这里会有一些表单控件 --&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">form</span>&gt;</span></span><br></pre></td></tr></table></figure>
<h4 id="3-2-单行文本输入框"><a href="#3-2-单行文本输入框" class="headerlink" title="3-2 单行文本输入框"></a>3-2 单行文本输入框</h4><p>单行输入框 代码</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">&lt;!-- action=&quot;&quot; 则表单信息将提交到当前页面--&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">form</span> <span class="attr">action</span>=<span class="string">&quot;&quot;</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;text&quot;</span> /&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">form</span>&gt;</span></span><br></pre></td></tr></table></figure>
<ol>
<li><p>占位文本”placeholder”</p>
<p>提示输入框的内容</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;text&quot;</span> <span class="attr">placeholder</span>=<span class="string">&quot;昵称&quot;</span> /&gt;</span></span><br></pre></td></tr></table></figure>
</li>
<li><p>输入框名字”name”</p>
<p>在有多个提交表单时，为了区分，在后面加上name</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;text&quot;</span> <span class="attr">placeholder</span>=<span class="string">&quot;昵称&quot;</span> <span class="attr">name</span>=<span class="string">&quot;nick&quot;</span> /&gt;</span></span><br></pre></td></tr></table></figure>
</li>
<li><p>value</p>
<p>在输入框内预填写用户昵称，用value</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;text&quot;</span> <span class="attr">placeholder</span>=<span class="string">&quot;昵称&quot;</span> <span class="attr">name</span>=<span class="string">&quot;nick&quot;</span> <span class="attr">value</span>=<span class="string">&quot;小明&quot;</span></span></span><br></pre></td></tr></table></figure>
</li>
</ol>
<ol>
<li><p>不可修改的输入框”readonly” 和 “disabled”</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;text&quot;</span> <span class="attr">placeholder</span>=<span class="string">&quot;昵称&quot;</span> <span class="attr">name</span>=<span class="string">&quot;nick&quot;</span> <span class="attr">value</span>=<span class="string">&quot;小明&quot;</span> <span class="attr">disabled</span> /&gt;</span></span><br></pre></td></tr></table></figure>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;text&quot;</span> <span class="attr">placeholder</span>=<span class="string">&quot;昵称&quot;</span> <span class="attr">name</span>=<span class="string">&quot;nick&quot;</span> <span class="attr">value</span>=<span class="string">&quot;小明&quot;</span> <span class="attr">readonly</span> /&gt;</span></span><br></pre></td></tr></table></figure>
</li>
</ol>
<p>disable 与 reandonly 的区别</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;text&quot;</span> <span class="attr">placeholder</span>=<span class="string">&quot;昵称&quot;</span> <span class="attr">name</span>=<span class="string">&quot;nick&quot;</span> <span class="attr">value</span>=<span class="string">&quot;小明&quot;</span> <span class="attr">disabled</span> /&gt;</span></span><br></pre></td></tr></table></figure>
<p>但是这两个是有一定区别的：</p>
<div class="table-container">
<table>
<thead>
<tr>
<th>属性</th>
<th>disabled</th>
<th>readonly</th>
</tr>
</thead>
<tbody>
<tr>
<td>对象</td>
<td>所有表单元素</td>
<td>input 和 textarea</td>
</tr>
<tr>
<td>作用</td>
<td>使文本框不能输入，当表单以 POST 或 GET 的方式提交时，使用了 disabled 的元素的值不会被传递出去</td>
<td>仅使文本框不能输入</td>
</tr>
<tr>
<td>外观 *</td>
<td>使文本框变灰</td>
<td>外观没有变化</td>
</tr>
</tbody>
</table>
</div>
<blockquote>
<p>外观 * ：在不同浏览器中输入框的外观可能会有区别，因此“readonly”和“disabled” 这两种输入框在外观上的差别可能与上表所述有所不同。</p>
</blockquote>
<h4 id="3-3-多行文本输入框和密码输入框"><a href="#3-3-多行文本输入框和密码输入框" class="headerlink" title="3-3 多行文本输入框和密码输入框"></a>3-3 多行文本输入框和密码输入框</h4><p>使用&lt; textarea</p>
<p>​         name=”sign”</p>
<p>​         rows=”5”</p>
<p>​         cols=”30”</p>
<p>​         placeholder=”请输入个性签名”&gt;&lt; /textarea&gt;</p>
<p>rows和cols分别表示行数和文本域的可视化宽度</p>
<p><strong>密码输入框</strong></p>
<p>将type=”password” 即可改为黑点</p>
<h4 id="3-4-单行框和复选框"><a href="#3-4-单行框和复选框" class="headerlink" title="3-4 单行框和复选框"></a>3-4 单行框和复选框</h4><p>radio</p>
<p>单选框 如 男 女</p>
<p>同一个单选题需要相同的name 属性</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">&lt;!-- type属性表示表单元素的类型，name属性表示表单元素的名称，value属性表示表单元素的值 --&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;radio&quot;</span> <span class="attr">name</span>=<span class="string">&quot;gender&quot;</span> <span class="attr">value</span>=<span class="string">&quot;male&quot;</span> /&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;radio&quot;</span> <span class="attr">name</span>=<span class="string">&quot;gender&quot;</span> <span class="attr">value</span>=<span class="string">&quot;female&quot;</span> /&gt;</span></span><br></pre></td></tr></table></figure>
<p>&lt; label&gt;</p>
<p>为了扩大选择范围</p>
<p>用&lt; label&gt; &lt; /label&gt;覆盖&lt; input&gt;</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">label</span>&gt;</span> <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;radio&quot;</span> <span class="attr">name</span>=<span class="string">&quot;gender&quot;</span> <span class="attr">value</span>=<span class="string">&quot;male&quot;</span> /&gt;</span>男 <span class="tag">&lt;/<span class="name">label</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">label</span>&gt;</span> <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;radio&quot;</span> <span class="attr">name</span>=<span class="string">&quot;gender&quot;</span> <span class="attr">value</span>=<span class="string">&quot;female&quot;</span> /&gt;</span>女 <span class="tag">&lt;/<span class="name">label</span>&gt;</span></span><br></pre></td></tr></table></figure>
<p>也可以写成</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">input</span> <span class="attr">id</span>=<span class="string">&quot;male&quot;</span> <span class="attr">type</span>=<span class="string">&quot;radio&quot;</span> <span class="attr">name</span>=<span class="string">&quot;gender&quot;</span> <span class="attr">value</span>=<span class="string">&quot;male&quot;</span> /&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">label</span> <span class="attr">for</span>=<span class="string">&quot;male&quot;</span>&gt;</span>男<span class="tag">&lt;/<span class="name">label</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">input</span> <span class="attr">id</span>=<span class="string">&quot;female&quot;</span> <span class="attr">type</span>=<span class="string">&quot;radio&quot;</span> <span class="attr">name</span>=<span class="string">&quot;gender&quot;</span> <span class="attr">value</span>=<span class="string">&quot;female&quot;</span> /&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">label</span> <span class="attr">for</span>=<span class="string">&quot;female&quot;</span>&gt;</span>女<span class="tag">&lt;/<span class="name">label</span>&gt;</span></span><br></pre></td></tr></table></figure>
<p>注意 id 需要 和 for=” “ 内容相同 产生对应关系</p>
<p><strong>复选框</strong></p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;checkbox&quot;</span> /&gt;</span></span><br></pre></td></tr></table></figure>
<h4 id="3-5-选项菜单"><a href="#3-5-选项菜单" class="headerlink" title="3-5 选项菜单"></a>3-5 选项菜单</h4><p>对于职业的选择等一些多选</p>
<p>用到&lt; select&gt;&lt; option&gt;</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">select</span> <span class="attr">name</span>=<span class="string">&quot;career&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">option</span> <span class="attr">value</span>=<span class="string">&quot;default&quot;</span>&gt;</span>请选择职业<span class="tag">&lt;/<span class="name">option</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">option</span> <span class="attr">value</span>=<span class="string">&quot;staff&quot;</span>&gt;</span>公司职员<span class="tag">&lt;/<span class="name">option</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">option</span> <span class="attr">value</span>=<span class="string">&quot;freelancer&quot;</span>&gt;</span>自由工作者<span class="tag">&lt;/<span class="name">option</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">option</span> <span class="attr">value</span>=<span class="string">&quot;student&quot;</span>&gt;</span>学生<span class="tag">&lt;/<span class="name">option</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">option</span> <span class="attr">value</span>=<span class="string">&quot;other&quot;</span>&gt;</span>其他<span class="tag">&lt;/<span class="name">option</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">select</span>&gt;</span></span><br></pre></td></tr></table></figure>
<p>注意提交时看到的数据为<strong>career:”student”</strong></p>
<p><strong>多选菜单</strong></p>
<p>在&lt; select&gt;标签添加<strong>mulyiple</strong> 属性 按住ctrl或 就可多选</p>
<h4 id="3-6-按钮"><a href="#3-6-按钮" class="headerlink" title="3-6 按钮"></a>3-6 按钮</h4><p>html中 用&lt; button&gt; 添加按钮</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">button</span>&gt;</span>注册<span class="tag">&lt;/<span class="name">button</span>&gt;</span></span><br></pre></td></tr></table></figure>
<p>按钮放在form中会自动提交表单数据，为了避免浏览器兼容问题，type=”submit”</p>
<h4 id="3-7-input标签小结"><a href="#3-7-input标签小结" class="headerlink" title="3-7 input标签小结"></a>3-7 input标签小结</h4><p><img src="https://liqur-1309874423.cos.ap-shanghai.myqcloud.com/h1.png" alt="img"></p>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="https://liqur.xyz">SuperXCR</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://liqur.xyz/SuperXCR/3ce8deb9.html">https://liqur.xyz/SuperXCR/3ce8deb9.html</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://liqur.xyz" target="_blank">SuperXCR</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/%E5%89%8D%E7%AB%AF/">前端</a><a class="post-meta__tags" href="/tags/HTML/">HTML</a></div><div class="post_share"><div class="social-share" data-image="https://liqur-1309874423.cos.ap-shanghai.myqcloud.com/h2.webp" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/SuperXCR/9a013174.html" title="CSS基础学习（1）"><img class="cover" src="https://liqur-1309874423.cos.ap-shanghai.myqcloud.com/s3.jpg" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">CSS基础学习（1）</div></div></a></div><div class="next-post pull-right"><a href="/SuperXCR/8eb491b8.html" title="Java基础学习（3）"><img class="cover" src="https://liqur-1309874423.cos.ap-shanghai.myqcloud.com/sceney4.jpg" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">Java基础学习（3）</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>相关推荐</span></div><div class="relatedPosts-list"><div><a href="/SuperXCR/9a013174.html" title="CSS基础学习（1）"><img class="cover" src="https://liqur-1309874423.cos.ap-shanghai.myqcloud.com/s3.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-09-01</div><div class="title">CSS基础学习（1）</div></div></a></div><div><a href="/SuperXCR/88b49e9a.html" title="CSS基础学习（2）"><img class="cover" src="https://liqur-1309874423.cos.ap-shanghai.myqcloud.com/sceney6.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-09-01</div><div class="title">CSS基础学习（2）</div></div></a></div><div><a href="/SuperXCR/3008f9ff.html" title="CSS基础学习（3）"><img class="cover" src="https://liqur-1309874423.cos.ap-shanghai.myqcloud.com/s11.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-09-01</div><div class="title">CSS基础学习（3）</div></div></a></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="https://i.loli.net/2021/02/24/5O1day2nriDzjSu.png" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">SuperXCR</div><div class="author-info__description">今日事，今日毕</div></div><div class="card-info-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">16</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">15</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">8</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/xxxxxx"><i class="fab fa-github"></i><span>Follow Me</span></a></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">This is my Blog</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%AE%A4%E8%AF%86HTML"><span class="toc-number">1.</span> <span class="toc-text">认识HTML</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-1%E5%85%83%E7%B4%A0%E7%9A%84%E7%BB%93%E6%9E%84"><span class="toc-number">1.1.</span> <span class="toc-text">1-1元素的结构</span></a></li></ol></li></ol></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link"><span class="toc-number"></span> <span class="toc-text">、、等</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-2-HTML%E7%9A%84%E5%B5%8C%E5%A5%97"><span class="toc-number">0.1.</span> <span class="toc-text">1-2 HTML的嵌套</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#1-3-%E5%AE%8C%E6%95%B4%E7%9A%84html%E6%96%87%E6%A1%A3%E7%BB%93%E6%9E%84"><span class="toc-number">0.2.</span> <span class="toc-text">1-3 完整的html文档结构</span></a></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/SuperXCR/7f8be62d.html" title="你不会还不会安装Maven吧"><img src="https://liqur-1309874423.cos.ap-shanghai.myqcloud.com/SuperXCR/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20230310162508.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="你不会还不会安装Maven吧"/></a><div class="content"><a class="title" href="/SuperXCR/7f8be62d.html" title="你不会还不会安装Maven吧">你不会还不会安装Maven吧</a><time datetime="2023-03-10T09:57:23.000Z" title="发表于 2023-03-10 17:57:23">2023-03-10</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/SuperXCR/c24675b4.html" title="MySQL"><img src="https://liqur-1309874423.cos.ap-shanghai.myqcloud.com/MySQL%E9%85%8D%E7%BD%AE/mysql.webp" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="MySQL"/></a><div class="content"><a class="title" href="/SuperXCR/c24675b4.html" title="MySQL">MySQL</a><time datetime="2022-11-21T06:48:00.000Z" title="发表于 2022-11-21 14:48:00">2022-11-21</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/SuperXCR/bfa56f5e.html" title="Navicat_Premium_16破解"><img src="https://liqur-1309874423.cos.ap-shanghai.myqcloud.com/s1.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Navicat_Premium_16破解"/></a><div class="content"><a class="title" href="/SuperXCR/bfa56f5e.html" title="Navicat_Premium_16破解">Navicat_Premium_16破解</a><time datetime="2022-09-26T02:55:58.000Z" title="发表于 2022-09-26 10:55:58">2022-09-26</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/SuperXCR/b2444a9.html" title="MySQL安装配置"><img src="https://liqur-1309874423.cos.ap-shanghai.myqcloud.com/MySQL%E9%85%8D%E7%BD%AE/mysql.webp" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="MySQL安装配置"/></a><div class="content"><a class="title" href="/SuperXCR/b2444a9.html" title="MySQL安装配置">MySQL安装配置</a><time datetime="2022-09-24T03:30:42.000Z" title="发表于 2022-09-24 11:30:42">2022-09-24</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/SuperXCR/a219e661.html" title="羊了个羊17最新版"><img src="https://liqur-1309874423.cos.ap-shanghai.myqcloud.com/s6.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="羊了个羊17最新版"/></a><div class="content"><a class="title" href="/SuperXCR/a219e661.html" title="羊了个羊17最新版">羊了个羊17最新版</a><time datetime="2022-09-16T05:18:03.000Z" title="发表于 2022-09-16 13:18:03">2022-09-16</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2023 By SuperXCR</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox/fancybox.umd.min.js"></script><div class="js-pjax"></div><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>